home *** CD-ROM | disk | FTP | other *** search
- Path: prof.ese-metz.fr!news
- From: Dominique.Pelle@ingenieurs.supelec.fr (Dominique PELLE)
- Newsgroups: comp.lang.c++
- Subject: template question
- Date: Wed, 17 Apr 1996 03:17:06 GMT
- Organization: Supelec Metz
- Message-ID: <4l0mk7$4n0@prof.ese-metz.fr>
- NNTP-Posting-Host: netrider-port2.supelec.fr
- X-Newsreader: Forte Free Agent 1.0.82
-
- Hello c++ gurus,
-
- I have a simple problem to solve:
-
- I would like to have an integer type on n bits and I would like
- to overload operator+ so that I can use it this way :
-
-
- integer<7> variable_7bits = 125;
- integer<4> variable_4bits = 15;
- integer<7> variable_7bits;
-
- variable_7bits = variable_7bits + variable_4bits;
-
- // 'variable_7bits' is now equal to :
- // -> 125+15
- // -> 140
- // -> 12 (because it is on 7 bits)
-
-
-
- No matter if it is coded on 32 bits, all it has to do, is perform
- operations so that it wraps around n bits AND ALSO detects if the
- operation overflows to warn the user.
-
-
- The question is :
- ~~~~~~~~~~~~~~~
-
- ????????? HOW CAN I WRITE THE OPERATOR+ FUNCTION ??????????
-
-
- --
- ==== Dominique PELLE =================================================
- e-mail --> Dominique.Pelle@ingenieurs.supelec.fr
- D. PELLE is Copyleft on IRC & Patator on FICS (chess.eerie.fr 5000)
- ==== Hidden DOS secret : add SET BUGS=OFF to your config.sys =========
-
-
-
-
-
-